<template>
  <div>
    <h1>采购信息查询</h1>
    <br>
    <span>查询采购信息</span><br>
    <el-input type="text" v-model="SQEName" placeholder="供应商" style="width: 10%"></el-input>
    <el-date-picker v-model="startTime" type="date" value-format="YYYY-MM-DD" style="width: 15%"
                    placeholder="起始日期">
    </el-date-picker>
    <el-date-picker v-model="endTime" type="date" value-format="YYYY-MM-DD" style="width: 15%"
                    placeholder="结束日期">
    </el-date-picker>
    <el-button type="primary" @click="query()">搜索</el-button>
    <br><br>
    <el-row>
      <el-table :data="SQEList" stripe>
        <el-table-column prop="supplierName" label="供应商名称"></el-table-column>
        <el-table-column prop="buyer" label="采购员"></el-table-column>
        <el-table-column prop="purchaseTime" label="采购时间"></el-table-column>
        <el-table-column label="查看详情">
          <template #default="scope">
            <el-button type="primary" @click="see(scope.row)">查看采购详情</el-button>

          </template>
        </el-table-column>
      </el-table>
      <el-pagination v-model:current-page="curPage" v-model:page-size="pageSize"
                     background :total="total" @current-change="changeCurPage()"></el-pagination>
    </el-row>
    <br>
    <el-button type="primary" @click="addSQE(scope.row.id)">添加供应商</el-button>
    <br><br>

    <el-dialog v-model="pick" title="添加"  style="width: 1000px" >
      <el-form :model="form" ref="form">
        <el-form-item label="客户名称">
          {{form.supplierName}}
        </el-form-item>
        <el-form-item label="负责人">
          {{form.buyer}}
        </el-form-item>
        <el-form-item label="负责人电话">
          {{form.purchaseTime}}
        </el-form-item>

      </el-form>
      <el-row>
        <el-table :data="purchaseInfoList" stripe >
          <el-table-column prop="commodityName" label="商品名称"></el-table-column>
          <el-table-column prop="manufacturer" label="品牌"></el-table-column>
          <el-table-column prop="purchasePrice" label="采购价"></el-table-column>
          <el-table-column label="数量" prop="amount">

          </el-table-column>
        </el-table>

      </el-row>
      <el-button  type="primary" @click="determine()">确定</el-button>

    </el-dialog>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "Home",
  created() {
    this.query()
  },
  data() {
    return {
      SQEList: [],
      SQEName: '',
      startTime: '',
      endTime: '',
      pick: false,
      form: {
        purchaseTime: '',
        supplierName: '',
        buyer:''
      },
      purchaseInfoList:[]
    }
  }, methods: {
    query() {
      let param = new URLSearchParams

      param.append('supplierName', this.SQEName)
      param.append('startTime', this.startTime)
      param.append('endTime', this.endTime)

      axios.post("/api/purchase/selectAll", param).then(res => {
        this.SQEList = res.data
      })


    },
    see(scope) {

      this.pick = true
      this.form = scope
      let param=new URLSearchParams()
      param.append('id',scope.purchaseId)

      axios.post("/api/PurchaseInfo/queryPurchaseInfoBean",param).then(res=>{
        this.purchaseInfoList=res.data
      })
    },
    determine(){
      this.pick = false
    },

  }
}
</script>

<style scoped>

</style>